import turtle
import random

turtle.setup(600, 600)
turtle.colormode(255)
turtle.speed(0)
for i in range(40):
    x = random.randint(-300, 280)
    y = random.randint(-300, 280)
    dis = random.randint(10, 40)
    r = random.randint(0, 255)
    g = random.randint(0, 255)
    b = random.randint(0, 255)
    turtle.up()
    turtle.goto(x, y)
    turtle.down()
    turtle.fillcolor(r, g, b)
    turtle.begin_fill()
    for j in range(4):
        turtle.forward(dis)
        turtle.left(90)
    turtle.end_fill()

turtle.done()

